import storage from '@system.storage';
import prompt from '@system.prompt';
import router from '@system.router';
import fetch from '@system.fetch';
import http from '@ohos.net.http';
//import qs from 'querystring';

export default {
    data: {
        title: "园区智能规划系统",
        isHarmonyOS: true,
        text2: "用户名",
        text3: "密码",
        text5: "登   录",
        Account: "XXXX",
        Password: "XXXX",
    },
    accountChange(e) {
        this.Account = e.value
    },
    passwordChange(e) {
        this.Password = e.value
    },
    onClick() {
        fetch.fetch({
            url: `https://XXXXXX:80/login?username=` + this.Account + `&password=` + this.Password,
            method: 'POST',
            responseType: "json",
            success: (response) => {
                console.info("fetch success");
                console.info(JSON.stringify(response.data));
                this.result = JSON.parse(response.data);
                console.info(JSON.stringify(this.result.data));
                if (this.result.data == "True") {
                    console.info("Login Success");
                    router.push({
                        uri: 'pages/page/page', //指定要跳转的页面
                    });
                } else {
                    console.info("Login Failed");
                    prompt.showToast({
                        message: "MIMA错误",
                        duration: 3000,
                    });
                }
            }
        })

    },
    click(){
        router.push({
            uri:'pages/register/register',
        });
    }
}

